package com.acme.bankapp.domain.bank;

public abstract class AbstractAccount implements Account {

	protected double balance = 0;
	
	public AbstractAccount(double amount) {
		this.balance = amount;
	}

	public long decimalValue(){
		return Math.round(balance);
	}
	
	public double getBalance() {
		return balance;
	}

	public int deposit(double amount) {
		if (amount <= 0) {
			return -1; 
		}
		balance += amount;
		return 0;
	}

	public int withdraw(double amount) {
		if (amount <= 0 ) {
			return -1;
		}
		assert (maximumAmountToWithdraw() < amount) : "amount > balance+overdraft";
		
		balance -= amount;
		return 0;
	}	
}
